#ifndef UDPSERVER_H
#define UDPSERVER_H

#include <QObject>
#include <QtNetwork/QUdpSocket>
#include <QThread>
#include "udpserverthread.h"

class UdpServer : public QObject
{
    Q_OBJECT
public:
    explicit UdpServer(QObject *parent = nullptr, quint16 port = 1234);
    ~UdpServer();

    void start();

    void setIPandPort(QString ip, quint16 port = 1234);

private slots:
    void handleDatagramReceived(const QByteArray &datagram, const QHostAddress &sender, quint16 senderPort);

    quint16 port;
    QString ip;

    UdpServerThread *serverThread;
};

#endif // UDPSERVER_H
